package com.xmb.common.controller.internal;

import com.xmb.common.exception.BusinessException;
import com.xmb.common.params.WxPayUnifiedOrdeParam;
import com.xmb.common.service.wx.WxCommonService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by lyndon on 2019/6/14.
 */
@RestController
@RequestMapping(value = "/order/pay_check")
public class OrderPayCheckController {

    @Autowired
    private WxCommonService wxCommonService;

    /**
     * 订单状态检查接口
     * @param
     */
    @PostMapping(value = "checkPayStatus")
    public Boolean checkPayStatus(@RequestBody WxPayUnifiedOrdeParam ordeParam) {
        if (ordeParam.getOrderId() <=0) {
            throw new BusinessException("业务订单号不合法");
        }
        if (StringUtils.isBlank(ordeParam.getOrderType())) {
            throw new BusinessException("订单类型不能为空");
        }
        return wxCommonService.checkPayStatus(ordeParam);
    }
}
